package com.superheroes.controller.open.excle;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.superheroes.utils.result.NotSayUncle;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.*;

@RestController
@RequestMapping("dc")
@Api(tags = "导出测试")
public class dcTestController {




    @ApiOperation(value = "导出接口")
    @GetMapping("test")
    public void test(HttpServletResponse response) throws Exception {


        TestBean m= new TestBean();
        m.setAge("718482598951035");
        m.setName("asdadad");
        m.setScore("152.02");
        m.setExamDate(new Date().toString());
        List<Object> rows =new ArrayList<>();
        rows.add(m);

        ExcelWriter writer= ExcelUtil.getBigWriter();
        writer.addHeaderAlias("name","我是你爸爸1");
        writer.addHeaderAlias("age","我是你爸爸2");
        writer.addHeaderAlias("score","我是你爸爸11");
        writer.addHeaderAlias("isPass","我是你爸爸111111111");
        writer.addHeaderAlias("examDate","我是你爸爸111");
        writer.setColumnWidth(0,20);
        writer.setColumnWidth(1,10);
        writer.setColumnWidth(2,30);
        writer.setColumnWidth(3,40);
        writer.setColumnWidth(4,60);
        writer.merge(4, "一班成绩单");
        BigExcelWriterUtils.exportExcel(writer,response,rows,"sadasdasdasd.xls");

    }



}